<!-- 
 Copyright 2009 University of  Washington
This code is released under the GPL version 3 - with a copy of the license included
@author Maya Hao Li
 -->
	
<%
	Page spPage = new Page();
	spPage.addJsLibrary("/javascript/lib/scriptaculous/src/effects.js");
	out.println(spPage.getPageOpenHtml());

	// get user
	LimsSession spSession = LimsSession.getSession(request);
	SeedpodUser user = spSession.getUser();
	out.println(spPage.getBanner(user));

	String name = user.getLabel(); 
%>

<script type="text/javascript">
	function loadUsers() {
					
					new Ajax.Request('../lims/user.jsp',
					{
						method:'get',
						onSuccess: function(transport) {
				   		 	var userContentBox = $('userContent');
				   		 	var response = transport.responseText;
				   		 	userContentBox.update(response);
						},
						
						onFailure: function() {
							userContentBox.update('Failed to load users');
						}
					}); 
				}
</script>

<div id="container">
<div id="content"><!--  content div --> <!-- actions  -->
<table id="maincontent">
	<tr>
		<td id="leftPane" rowspan=99>
		<h4 align="left">Hello, <%=name%>!</h4>
		<table cellpadding="10" cellspacing="10">
			<tr>
				<td class="sectionTitle"><a href="createInstance.jsp"><img
					src="../images/favorites.png"><br>
				Enter new data</a></td>
				<td class="sectionTitle"><a href="#"><img
					src="../images/bullet.png"><br>
				Browse data</a></td>
			</tr>
			<tr>
				<td class="sectionTitle"><a href="#"><img
					src="../images/search.png"><br>
				Search</a></td>
				<td class="sectionTitle"><a href="customize.jsp	"><img
					src="../images/user.png"><br>
				Customize</a></td>
			</tr>
		</table>

		</td>
		<!--  end action choices -->

		<td id="rightPane" ><!--  right pane cell -->

		<table style="height: 100%; border-left: 1px solid #dddddd;">
			<!-- right pane table -->
			<tr><!--  latest updates -->
				<td>
				<div id="latest" class="widgetBox" style="width:300px">
				<div class="widgetBoxTitle">Latest database updates</div>
				<div class="widgetBoxContent" id="updateContent">
				<ul>
				<%
					Logger logger = new Logger(spSession);
					ArrayList<String> logs = logger.getLast(10);
					for (String l : logs )
						out.print("<li>"+l+"</li>");
				%>

					<li>something here</li>
					<li>something here</li>
					<li>refresh</li>
					<li>something here</li>
				</ul>
				</div><!-- end update content  -->
				</div>	<!--  end widgetBox for last updates -->
				</td>
			</tr>

			<!--  end latest updates -->

			<tr><td>
				<!--  lab users -->
				<div id="users" class="widgetBox">
				<div class="widgetBoxTitle">LIMS users</div>
				<div class="widgetBoxContent" id="userContent">
				
				
				<script>this.onload = loadUsers();</script>
				
				</div><!-- end widgetbox content -->
				</div><!--  end widget box -->
				
				</td>
			</tr>
		</table>
		<!--  end right pane table --></td>
	</tr>
</table>
<!-- end main content table --> <!-- end content div --></div>

<!-- end container div --></div>

<%
	out.println(spPage.getFooter());
	out.println(spPage.getPageEndHtml() );
%>
<%@page import="seedpod.webapp.view.Page"%>
<%@page import="seedpod.webapp.LimsSession"%>
<%@page import="seedpod.model.custom.SeedpodUser"%>
<%@page import="seedpod.webapp.controller.Logger"%>
<%@page import="java.util.ArrayList" %>
